package cn.pping.pet.service.impl;

import cn.pping.org.domain.Department;
import cn.pping.pet.domain.Pet;
import cn.pping.pet.domain.PetDetail;
import cn.pping.pet.mapper.PetDetailMapper;
import cn.pping.pet.mapper.PetMapper;
import cn.pping.pet.service.IPetService;
import cn.pping.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author pping
 * @since 2022-08-06
 */
@Service
public class PetServiceImpl extends BaseServiceImpl<Pet> implements IPetService {
    @Autowired
    private PetMapper petMapper;
    @Autowired
    private PetDetailMapper petDetailMapper;

    @Override
    public void add(Pet pet) {
        petMapper.add(pet);
        PetDetail petDetail = pet.getPetDetail();
        petDetail.setPet_id(pet.getId());
        petDetailMapper.add(petDetail);
    }

    @Override
    public void update(Pet pet) {
        petMapper.update(pet);
        petDetailMapper.update(pet.getPetDetail());
    }

    @Override
    public void onSale(List<Long> ids) {
        Date date = new Date();
        petMapper.onSale(ids ,date);
    }

    @Override
    public void offSale(List<Long> ids) {
        Date date = new Date();
        petMapper.offSale(ids ,date);
    }

}
